<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>入库管理</el-breadcrumb-item>
    </el-breadcrumb>
    <!--列表-->
    <el-table size="small" :data="entryList" highlight-current-row v-loading="loading" border element-loading-text="拼命加载中" style="width: 100%;">
      <el-table-column align="center" prop="id" label="入库单号" width="100">
      </el-table-column>
      <el-table-column align="center" prop="purchaseOrder.goodsName" label="商品名" width="150">
      </el-table-column>
      <el-table-column align="center" prop="purchaseOrderId" label="入库订单号" width="150">
      </el-table-column>
      <el-table-column align="center" prop="purchaseOrder.amount" label="数量" width="150">
      </el-table-column>
      <el-table-column align="center" prop="createTime" label="申请时间" width="200"></el-table-column>
      <el-table-column align="center" prop="status" label="入库状态" width="100">
        <template slot-scope="scope">
          <span :style="{color: scope.row.status ? '#4fc08d' : '#ff6600'}">{{scope.row.status ? '已入库' : '未入库'}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作" min-width="200">
        <template slot-scope="scope">
          <el-button size="mini" type="success" @click="nowEntry(scope.$index, scope.row)">立即入库</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <Pagination v-bind:child-msg="pageQuery" @callFather="callFather"></Pagination>
  </div>
</template>

<script>
import Pagination from '../../components/Pagination'
export default {
  name:'ManagerEntry',
  data() {
    return {
      entryList: [], // 未入库列表
      pageQuery: {
        pageNum: 1,
        pageSize: 10
      },
      loading: false //是显示加载
    }
  },
  // 注册组件
  components: {
    Pagination
  },
  created() {
    this.godownEntryList()
  },
  methods: {
    /**
     * 获取未入库列表
     */
    godownEntryList() {
      this.loading = true
      this.$api.manager.godownEntryList(this.pageQuery).then(res => {
        if (res.code === 200) {
          this.entryList = res.data.records
          this.loading = false
        }
      }).catch(err => this.loading = false)
    },
    /**
     * 分页插件事件
     */
    callFather(parm) {
      this.pageQuery.pageNum = parm.currentPage
      this.pageQuery.pageSize = parm.pageSize
      this.godownEntryList()
    },
    /**
     * 立即入库
     */
    nowEntry (index, entry) {
      let params = {
        id: entry.id,
        purchaseOrderId: entry.purchaseOrderId
      }
      this.$api.manager.godownEntryNow(params).then(res => {
        if (res.code === 200) {
          this.$message({
            type: 'success',
            message: '已成功入库'
          })
          this.godownEntryList()
        }
      })
    }
  }
}
</script>

<style>
.comment-search {
  margin-top: 20px;
}
.commentRole {
  width: 100%;
}
</style>

 
 